/**
 * Project Name:YCApiServer-Api
 * File Name:TuningMusicService.java
 * Package Name:com.yc.music.service.service103
 * Date:2016年5月18日下午3:04:13
 * Copyright (c) 2016 
 *
 */
package com.yc.music.service.service103;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindingResult;

import com.esotericsoftware.minlog.Log;
import com.yc.music.common.context.YcContext;
import com.yc.music.common.util.AudioUtil;
import com.yc.music.common.util.BindingResultUtil;
import com.yc.music.common.util.FilesUtil;
import com.yc.music.common.util.QiNiuUpload;
import com.yc.music.common.util.RoomUtil;
import com.yc.music.context.YtConstant;
import com.yc.music.mapper.cache.HotTempCacheMapper;
import com.yc.music.mapper.cache.HtmlConfigCacheMapper;
import com.yc.music.mapper.cache.MusicActivityCacheMapper;
import com.yc.music.mapper.dao.HotTempMapper;
import com.yc.music.mapper.dao.MusicActivityFlowMapper;
import com.yc.music.mapper.dao.TunningLogMapper;
import com.yc.music.mapper.dao.UserMapper;
import com.yc.music.mapper.dao.WorkMapper;
import com.yc.music.model.ShareModel;
import com.yc.music.model.accompaniment.HotVo;
import com.yc.music.model.activity.MusicActivityFlow;
import com.yc.music.model.activity.MusicActivityVo;
import com.yc.music.model.htmlconfig.HtmlConfig;
import com.yc.music.model.musicWork.SaveMusic;
import com.yc.music.model.musicuser.MusicUserVo;
import com.yc.music.model.searchvo.SearchWork;
import com.yc.music.model.tunning.TunningLog;
import com.yc.music.model.tunningmusic.TunningMusic;

/**
 * 调音，合成 service
 * ClassName: TuningMusicService <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2016年5月18日 下午3:04:13 <br/>
 *
 * @author panguixiang
 * @version 
 */
@Service
public class TuningMusicService {
	
	private static Logger logger = Logger.getLogger(TuningMusicService.class);
	
	@Autowired
	private HotTempCacheMapper hotTempCacheMapper;
	
	@Autowired
	private HotTempMapper hotTempMapper;
	
	@Autowired
	private WorkMapper workMapper;
	
	@Autowired
	private TunningLogMapper tunningLogMapper;
	
	@Autowired
	private UserMapper userMapper;
	
	@Value("${SERVER_FILE_PATH}")
	private String SERVER_FILE_PATH;
	
	@Value("${audio_buckname}")
	private String audio_buckname;
	
	@Value("${linux_ffmpeg}")
	private String linux_ffmpeg;
	
	@Value("${linux_ffmpeg_effect}")
	private String linux_ffmpeg_effect;
	
	@Value("${linux_ffmpeg_mixAudioNoHeadSet}")
	private String linux_ffmpeg_mixAudioNoHeadSet;
	
	
	@Autowired
	private HtmlConfigCacheMapper htmlConfigCacheMapper;
	
	@Autowired
	private MusicActivityFlowMapper musicActivityFlowMapper;
	
	@Autowired
	private MusicActivityCacheMapper musicActivityCacheMapper;

	public Map<String,Object> tunningMusic(Map<String,Object> result,
			TunningMusic tunningMusic,BindingResult binding) throws Exception{
		Map<String,Object> tunningUrlMap = new HashMap<String,Object>();
		String valiterMsg = BindingResultUtil.getBindErrorMsg(binding);
		if(StringUtils.isNotBlank(valiterMsg)) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, valiterMsg);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			return result;
		}
		tunningUrlMap.put(YtConstant.oldPath, tunningMusic.getMusicurl());//原音频文件mp3地址
		HotVo hotVo = hotTempCacheMapper.getHoVoById(tunningMusic.getHotid());
		if(hotVo==null || StringUtils.isBlank((hotVo.getMp3()).trim())) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.HOT_TEMP_NULL);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			return result;
		}
		logger.info("*****************调用音频处理开始******************");
		Long startTime=System.currentTimeMillis();
		String outmp3path = doTunning(tunningMusic,hotVo.getMp3(),tunningMusic.getUid(),tunningMusic.getEffect());
		Long endTime=System.currentTimeMillis();
		logger.info("*****************调用音频处理结束******************总耗时："+(endTime-startTime)/1000+" 秒");
		
		tunningUrlMap.put(YtConstant.newPath, outmp3path);//合成，调音后的mp3地址
		tunningUrlMap.put(YtConstant.effect,tunningMusic.getEffect());//音效
		
		//返回的地址为空则合成失败
		if (null==outmp3path) {
			result.put(YcContext.CODE, 500);
			result.put(YcContext.MESSAGE,  YtConstant.outfail);
			result.put(YcContext.DATA,tunningUrlMap);
			return result;
		}else{
			result.put(YcContext.CODE, 200);
			result.put(YcContext.MESSAGE,  YcContext.EMPTY_STRING);
			result.put(YcContext.DATA,tunningUrlMap);
			return result;
		}
		
	}
	
	/**
	 * 
	 * saveMusic:(发布,修改 歌曲). <br/> 
	 *
	 * @author panguixiang
	 * @param result
	 * @param saveMusic
	 * @param binding
	 * @return
	 * @since JDK 1.7
	 */
	public Map<String,Object> optMusic(Map<String,Object> result, SaveMusic saveMusic,
			BindingResult binding) throws Exception{
		String valiterMsg = BindingResultUtil.getBindErrorMsg(binding);
		if(StringUtils.isNotBlank(valiterMsg)) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, valiterMsg);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			return result;
		}
		HotVo hotVo = hotTempCacheMapper.getHoVoById(saveMusic.getHotid());
		if(hotVo==null || StringUtils.isBlank((hotVo.getMp3()).trim())) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.HOT_TEMP_NULL);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			return result;
		}
		//判断author字段是否为空，为空则查询作者名
		if (null==saveMusic.getAuthor()||""==saveMusic.getAuthor()) {
			MusicUserVo vo =userMapper.getUservo(saveMusic.getUid());
			saveMusic.setAuthor(vo.getNickname());
		}
		
		String mp3path=saveMusic.getMp3();
		mp3path=SERVER_FILE_PATH.concat(mp3path);
		saveMusic.setMp3times(AudioUtil.getAudioTime(mp3path));
		String mp3=saveMusic.getMp3();
		if(mp3.charAt(0)==YcContext.Slashchar){//先去掉'/'
			mp3=mp3.replaceFirst(YcContext.Slash, YcContext.EMPTY_STRING);
		}
		if((saveMusic.getPic()).charAt(0)!=YcContext.Slashchar) {
			saveMusic.setPic(YcContext.Slash.concat(saveMusic.getPic()));
		}
		QiNiuUpload.uploadQiNiu(mp3path, audio_buckname, mp3);
		//上传七牛后，需要持久化到数据库的路径需要'/'
		if(mp3.charAt(0)!=YcContext.Slashchar) {
			saveMusic.setMp3(YcContext.Slash.concat(mp3));
		}
		if(saveMusic.getId()==null) {
			//保存之前先过滤是否已经存在重复数据，通过pic路径查询
			List<SearchWork> list=workMapper.searchMusicList(saveMusic.getPic(), 0, 10);
			if (list.size()>0) {
				result.put("listsize", list.size());
				return result;
			}
			workMapper.saveMusic(saveMusic);
			if(saveMusic.getHotid()!=null) {
				hotTempMapper.addHotUseNum(saveMusic.getHotid());
			}
		} else {
			workMapper.updateMusic(saveMusic);
		}
		
		HtmlConfig config = htmlConfigCacheMapper.getHtmlConfig(YtConstant.musicShare);//歌曲分享页
		
		//作品参加活动
		int itemid=workMapper.getWorkByPicUrl(saveMusic.getPic());
		
		//分享链接
		ShareModel share = new ShareModel();
		if(config!=null) {
			share.setShareurl(config.getUrl());
			share.setItemid(itemid);
		}
		
		logger.info("歌曲分享链接"+share);
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YtConstant.SYS_SUCCSS_MSG);
		result.put(YcContext.DATA,share);
		
		//发布成功后删除之前的音效和多余的合成文件
		//获取最终合成的url
		String mp3Url=saveMusic.getMp3();
		
		String delPathFile=FilesUtil.deleteFile(SERVER_FILE_PATH, mp3Url);
		logger.info("发布歌曲后删除不需要的生成文件："+delPathFile);
		return result;
	}
	
	
	public Map<String,Object> musicActivity(Map<String,Object> result, SaveMusic saveMusic,Integer aid,
			BindingResult binding) throws Exception{
		String valiterMsg = BindingResultUtil.getBindErrorMsg(binding);
		if(StringUtils.isNotBlank(valiterMsg)) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, valiterMsg);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			return result;
		}
		
		//先查询活动是否存在
		MusicActivityVo musicActivityVo=musicActivityCacheMapper.getMusicActivityById(aid);
		if (null==musicActivityVo) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.ACTIVITY_IS_NOT_EXIST);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			return result;
		}
		
		HotVo hotVo = hotTempCacheMapper.getHoVoById(saveMusic.getHotid());
		if(hotVo==null || StringUtils.isBlank((hotVo.getMp3()).trim())) {
			result.put(YcContext.CODE, 400);
			result.put(YcContext.MESSAGE, YtConstant.HOT_TEMP_NULL);
			result.put(YcContext.DATA,YcContext.EMPTY_STRING);
			return result;
		}
		

		String mp3path=saveMusic.getMp3();
		mp3path=SERVER_FILE_PATH.concat(mp3path);
		saveMusic.setMp3times(AudioUtil.getAudioTime(mp3path));
		String mp3=saveMusic.getMp3();
		if(mp3.charAt(0)==YcContext.Slashchar){//先去掉'/'
			mp3=mp3.replaceFirst(YcContext.Slash, YcContext.EMPTY_STRING);
		}
		if((saveMusic.getPic()).charAt(0)!=YcContext.Slashchar) {
			saveMusic.setPic(YcContext.Slash.concat(saveMusic.getPic()));
		}
		QiNiuUpload.uploadQiNiu(mp3path, audio_buckname, mp3);
		//上传七牛后，需要持久化到数据库的路径需要'/'
		if(mp3.charAt(0)!=YcContext.Slashchar) {
			saveMusic.setMp3(YcContext.Slash.concat(mp3));
		}
		if(saveMusic.getId()==null) {
			//保存之前先过滤是否已经存在重复数据，通过pic路径查询
			List<SearchWork> list=workMapper.searchMusicList(saveMusic.getPic(), 0, 10);
			if (list.size()>0) {
				result.put("listsize", list.size());
				return result;
			}
			workMapper.saveMusic(saveMusic);
			if(saveMusic.getHotid()!=null) {
				hotTempMapper.addHotUseNum(saveMusic.getHotid());
			}
		} 
		
		//作品参加活动
		int itemid=workMapper.getWorkByPicUrl(saveMusic.getPic());//作品id
		
		//活动流水
		MusicActivityFlow flow =new MusicActivityFlow();
		flow.setActivityid(aid);
		flow.setUserid(saveMusic.getUid());
		flow.setWorkid(itemid);
		//活动类型 1表示歌曲 2表示歌词
		flow.setType(1);
		
		//先查询是否参加过该活动
		MusicActivityFlow activityFlow=musicActivityFlowMapper.getActivityFlowById(aid,saveMusic.getUid());
				
		if(null!=activityFlow){
			//参加过则直接覆盖作品id
			musicActivityFlowMapper.updateActivityFlow(flow);
		}else{
			musicActivityFlowMapper.saveActivityFlow(flow);
		}
		
		//获取分享链接
		HtmlConfig config = htmlConfigCacheMapper.getHtmlConfig(YtConstant.musicShare);//歌曲分享页

		//分享链接
		ShareModel share = new ShareModel();
		if(config!=null) {
			share.setShareurl(config.getUrl());
			share.setItemid(itemid);
		}
		
		result.put(YcContext.CODE, 200);
		result.put(YcContext.MESSAGE, YtConstant.SYS_SUCCSS_MSG);
		result.put(YcContext.DATA,share);
		
		//发布成功后删除之前的音效和多余的合成文件
		//获取最终合成的url
		String mp3Url=saveMusic.getMp3();
				
		String delPathFile=FilesUtil.deleteFile(SERVER_FILE_PATH, mp3Url);
		logger.info("发布歌曲（活动）后删除不需要的生成文件："+delPathFile);
		return result;
	}
	
	/**
	 * 调音操作
	 * doTunning:(这里用一句话描述这个方法的作用). <br/> 
	 * @author panguixiang
	 * @param tunningMusic
	 * @param hotPath  伴奏的绝对路径
	 * @return
	 * @throws Exception
	 * @since JDK 1.7
	 */
	private String doTunning(TunningMusic tunningMusic, String hotPath,long uid,int effect) throws Exception{

		String musicUrl = tunningMusic.getMusicurl();
		musicUrl=RoomUtil.replaceAllDomain(musicUrl);//去掉域名
		logger.info("-----待合成mp3音频的地址- ----"+musicUrl+" , 伴奏地址==="+hotPath+",选择的音效:"+effect);
		
		String musicPaht = (musicUrl.replace(".mp3", "")).replace(".wav", "");
		
		String outMusicUrl=musicPaht.concat("_out.mp3");//合成最终的文件
		
		String effectMusicUrl0=musicPaht.concat("_effect0.mp3");//音效处理后文件0
		
		String effectMusicUrl1=musicPaht.concat("_effect1.mp3");//音效处理后文件 1
		
		String effectMusicUrl2=musicPaht.concat("_effect2.mp3");//音效处理后文件 2
		
		String effectMusicUrl3=musicPaht.concat("_effect3.mp3");//音效处理后文件 3
		
		String effectMusicUrl4=musicPaht.concat("_effect4.mp3");//音效处理后文件 4
		
		String outMusicUrl0 = musicPaht.concat("_out0.mp3");//合成最终的文件0
		
		String outMusicUrl1 = musicPaht.concat("_out1.mp3");//合成最终的文件1
		
		String outMusicUrl2 = musicPaht.concat("_out2.mp3");//合成最终的文件2
		
		String outMusicUrl3 = musicPaht.concat("_out3.mp3");//合成最终的文件3
		
		String outMusicUrl4 = musicPaht.concat("_out4.mp3");//合成最终的文件4
		
		if(tunningMusic.getUseheadset()==1) {//戴耳机，需要合成操作
			String outurl=null;
			//效果为0，不进行音效处理
			if(effect==0){
				effectMusicUrl0=musicUrl;
				//只进行合成，不进行音效处理
				logger.info("*****************只进行合成，不进行音效处理开始******************");
				Long startTime=System.currentTimeMillis();
				outurl= this.composeMusic(musicUrl, effectMusicUrl0, effect, hotPath, outMusicUrl0, uid);
				Long endTime=System.currentTimeMillis();
				logger.info("*****************只进行合成，不进行音效处理结束******************总耗时："+(endTime-startTime)/1000+" 秒");
			}else if(effect==1){
				logger.info("*****************音效1处理开始******************");
				Long startTime=System.currentTimeMillis();
				outurl= this.effect(musicUrl, effectMusicUrl1, effect, hotPath, outMusicUrl1, uid);
				Long endTime=System.currentTimeMillis();
				logger.info("*****************音效1处理结束******************总耗时："+(endTime-startTime)/1000+" 秒");
			}else if(effect==2){
				logger.info("*****************音效2处理开始******************");
				Long startTime=System.currentTimeMillis();
				outurl= this.effect(musicUrl, effectMusicUrl2, effect, hotPath, outMusicUrl2, uid);
				Long endTime=System.currentTimeMillis();
				logger.info("*****************音效2处理结束******************总耗时："+(endTime-startTime)/1000+" 秒");
			}else if(effect==3){
				logger.info("*****************音效3处理开始******************");
				Long startTime=System.currentTimeMillis();
				outurl= this.effect(musicUrl, effectMusicUrl3, effect, hotPath, outMusicUrl3, uid);
				Long endTime=System.currentTimeMillis();
				logger.info("*****************音效3处理结束******************总耗时："+(endTime-startTime)/1000+" 秒");
			}else if(effect==4){
				logger.info("*****************音效4处理开始******************");
				Long startTime=System.currentTimeMillis();
				outurl= this.effect(musicUrl, effectMusicUrl4, effect, hotPath, outMusicUrl4, uid);
				Long endTime=System.currentTimeMillis();
				logger.info("*****************音效4处理结束******************总耗时："+(endTime-startTime)/1000+" 秒");
			}
			return outurl;
			
		}else {   //不带耳机，需要进行音量的调节
//			StringBuffer buffer = new StringBuffer();
//			buffer.append(linux_ffmpeg_mixAudioNoHeadSet).append(" ").append(SERVER_FILE_PATH).
//			append(musicUrl).append(" ").append(SERVER_FILE_PATH).append(outMusicUrl);
//			logger.info("-----不戴耳机合成命令-----==="+buffer.toString());
//			AudioUtil.doAudioTuning(buffer.toString());
//			Thread.sleep(5000);
//			/**
//			 * 持久化合成记录到数据库表
//			 */
//			TunningLog log = new TunningLog();//将本次合成操作记录放入调音日志表里
//			log.setUid(uid);
//			log.setBasemusic(musicUrl);
//			log.setHotempmusic(hotPath);
//			log.setTunningmusic(outMusicUrl);
//			tunningLogMapper.saveTunningLog(log);
//			
//			//合成结束后判断合成的文件是否存在
//			String out=FilesUtil.existsFile(SERVER_FILE_PATH, outMusicUrl);
//			if (null==out) {
//				outMusicUrl=out;//文件不存在则返回空地址
//			}
			return musicUrl;
		}
	}
	
	/**
	 * 
	 * effect:音效处理和伴奏合成. <br/> 
	 *
	 * @author qinhaiguan  
	 * @param musicUrl  原人声url
	 * @param effectMusicUrl   音效合成后的url
	 * @param effect 音效值 效果 0 无音效处理 1 profession(专业) 2 singer（唱将） 3 magic（魔音） 4 ktv
	 * @param hotPath 伴奏地址
	 * @param outMusicUrl  最终合成url
	 * @param uid 用户id
	 * @return
	 * @throws Exception
	 * @since JDK 1.7
	 */
	private String effect(String musicUrl,String effectMusicUrl,int effect,String hotPath,String outMusicUrl,long uid) throws Exception{
		//进行音效处理
		//先判断音效文件是否存在
		File file =new File(SERVER_FILE_PATH+effectMusicUrl);
		//文件不存在才进行音效处理
		if(!file.exists()){   
			StringBuffer buf = new StringBuffer();
			buf.append(linux_ffmpeg_effect).append(" ")
			.append(SERVER_FILE_PATH).append(musicUrl).append(" ")
			.append(SERVER_FILE_PATH).append(effectMusicUrl).append(" ")
			.append(effect);
			logger.info("-----音效合成命令-----"+buf.toString());
			AudioUtil.doAudioTuning(buf.toString());
			Thread.sleep(3000);
		}
		
		//进行人声和伴奏合成
		//先判断合成文件文件是否存在
		file =new File(SERVER_FILE_PATH+outMusicUrl);
		//文件不存在才进行合成处理
		if(!file.exists()){  
			StringBuffer buffer = new StringBuffer();
			buffer.append(linux_ffmpeg).append(" ")
			.append(SERVER_FILE_PATH).append(effectMusicUrl).append(" ")
			.append(SERVER_FILE_PATH).append(hotPath).append(" ")
			.append(SERVER_FILE_PATH).append(outMusicUrl);
			logger.info("-----音效后处理后人声和伴奏合成命令-----"+buffer.toString());
			Thread.sleep(1000);
			logger.info("*****************音效处理C++部分开始******************");
			Long startTime=System.currentTimeMillis();
			AudioUtil.doAudioTuning(buffer.toString());
			Long endTime=System.currentTimeMillis();
			logger.info("*****************音效处理C++部分结束******************总耗时："+(endTime-startTime)/1000+" 秒");
		}
		
		//合成结束后判断合成的文件是否存在
		String out=FilesUtil.existsFile(SERVER_FILE_PATH, outMusicUrl);
		if (null==out) {
			outMusicUrl=out;//文件不存在则返回空地址
		}
		
		/**
		 * 持久化合成记录到数据库表
		 */
		TunningLog log = new TunningLog();//将本次合成操作记录放入调音日志表里
		log.setUid(uid);
		log.setBasemusic(musicUrl);
		log.setHotempmusic(hotPath);
		log.setTunningmusic(outMusicUrl);
		tunningLogMapper.saveTunningLog(log);
		return outMusicUrl;
		
	}
	
	/**
	 * composeMusic:进行人声和伴奏合成,无音效. <br/> 
	 *
	 * @author qinhaiguan  
	 * @param musicUrl  原人声url
	 * @param effectMusicUrl   音效合成后的url
	 * @param effect 音效值 效果 0 无音效处理 1 profession(专业) 2 singer（唱将） 3 magic（魔音） 4 ktv
	 * @param hotPath 伴奏地址
	 * @param outMusicUrl  最终合成url
	 * @param uid 用户id
	 * @return
	 * @throws Exception
	 * @since JDK 1.7
	 */
	private String composeMusic(String musicUrl,String effectMusicUrl,int effect,String hotPath,String outMusicUrl,long uid) throws Exception{
		//先判断需要合成文件是否存在
		File file =new File(SERVER_FILE_PATH+outMusicUrl);
		//文件不存在才进行合成处理
		if(!file.exists()){   
			StringBuffer buffer = new StringBuffer();
			buffer.append(linux_ffmpeg).append(" ")
			.append(SERVER_FILE_PATH).append(effectMusicUrl).append(" ")
			.append(SERVER_FILE_PATH).append(hotPath).append(" ")
			.append(SERVER_FILE_PATH).append(outMusicUrl);
			logger.info("-----没有音效处理的人声和伴奏合成命令-----"+buffer.toString());
			Thread.sleep(1000);
			logger.info("*****************只进行合成，不进行音效处理C++部分开始******************");
			Long startTime=System.currentTimeMillis();
			AudioUtil.doAudioTuning(buffer.toString());
			Long endTime=System.currentTimeMillis();
			logger.info("*****************只进行合成，不进行音效处理C++部分结束******************总耗时："+(endTime-startTime)/1000+" 秒");
			
		}
		//合成结束后判断合成的文件是否存在
		String out=FilesUtil.existsFile(SERVER_FILE_PATH, outMusicUrl);
		if (null==out) {
			outMusicUrl=out;//文件不存在则返回空地址
		}
		/**
		 * 持久化合成记录到数据库表
		 */
		TunningLog log = new TunningLog();//将本次合成操作记录放入调音日志表里
		log.setUid(uid);
		log.setBasemusic(musicUrl);
		log.setHotempmusic(hotPath);
		log.setTunningmusic(outMusicUrl);
		tunningLogMapper.saveTunningLog(log);
		return outMusicUrl;
	}
//	private String soundEffect(TunningMusic tunningMusic, String hotPath,long uid,int effect) throws Exception{
//
//		String musicUrl = tunningMusic.getMusicurl();
//		musicUrl=RoomUtil.replaceAllDomain(musicUrl);//去掉域名
//		logger.info("-----待合成mp3音频的地址- ----"+musicUrl+" , 伴奏地址==="+hotPath+",选择的音效:"+effect);
//		String musicPaht = (musicUrl.replace(".mp3", "")).replace(".wav", "");
//	
//		String outMusicUrl = musicPaht.concat("_out.mp3");//合成最终的文件
//		
//		if(tunningMusic.getUseheadset()==1) {//戴耳机，需要合成操作
//			
//			StringBuffer buffer = new StringBuffer();
//			buffer.append(linux_ffmpeg).append(" ").append(SERVER_FILE_PATH).
//			append(musicUrl).append(" ").append(SERVER_FILE_PATH).append(hotPath).append(" ").
//			append(SERVER_FILE_PATH).append(outMusicUrl).append(" ").append(effect);
//			logger.info("-----合成命令-----==="+buffer.toString());
//			AudioUtil.doAudioTuning(buffer.toString());
//			Thread.sleep(5000);
//			/**
//			 * 持久化合成记录到数据库表
//			 */
//			TunningLog log = new TunningLog();//将本次合成操作记录放入调音日志表里
//			log.setUid(uid);
//			log.setBasemusic(musicUrl);
//			log.setHotempmusic(hotPath);
//			log.setTunningmusic(outMusicUrl);
//			tunningLogMapper.saveTunningLog(log);
//			return outMusicUrl;
//		} else {
//			return musicUrl;
//		}
//	}
}
